mui.plusReady(function() {
	plus.navigator.setStatusBarBackground("#FF7234");
	console.log(plus.webview.currentWebview().id)
	$('#account').val(localStorage.getItem('phone'))
	var isManual = false; //标志按钮最后状态
	console.log(localStorage.getItem('isManual'))
	if(localStorage.getItem('isManual') == "true") {
		isManual = true;
		$('#autoLogin').addClass('mui-active')
		$('#password').val(localStorage.getItem("password"))
	}

	document.getElementById("autoLogin").addEventListener('toggle', function(event) {
		isManual = !isManual;
		//					console.log(isManual)
		if(isManual) {
			localStorage.setItem("isManual", isManual);
			localStorage.setItem("password", $('#password').val());
		} else {
			localStorage.setItem("password", "")
			localStorage.setItem("isManual", "false")
		}
	});
	//登陆
	$('.mui-btn-block').bind("tap", function() {

		if($("#account").val() == "") {
			mui.toast("手机号不能为空")
			return;
		}
		if(!isPoneAvailable($("#account").val())) {
			mui.toast("请输入正确的手机号")
			return
		}
		if($("#password").val() == "") {
			mui.toast("密码不能为空")
			return;
		}
		var subData = {
			phone: $("#account").val(),
			password: $("#password").val(),
			openId: ""
		}

		postServer('/app/member/login', $.param(subData), function(res) {
			if(res.success) {
				localStorage.setItem('phone', $("#account").val())
				localStorage.setItem("password", $('#password').val());
				localStorage.setItem('userinfo', JSON.stringify(res.data))
				plus.webview.getLaunchWebview().evalJS("activeModel()")
				plus.webview.close(plus.webview.currentWebview())
			} else {
				mui.toast(res.message)
			}
		}, function(res) {
			localStorage.setItem("password", "")
			localStorage.setItem("isManual", "false")
			mui.toast(res.message)
		});
	})
	//用户注册
	$('.linktextreg').bind('tap', function() {
		openurl('register.html')
	})
	//忘记密码
	$('.linktextrepwd').bind('tap', function() {
		openurl('resetpassword.html')
	})
})